const path = require('path')

const config = {
  projectName: 'ycs-t',
  date: '2020-12-6',
  designWidth: 750,
  deviceRatio: {
    640: 2.34 / 2,
    750: 1,
    828: 1.81 / 2
  },
  sourceRoot: 'src',
  outputRoot: 'dist',
  plugins: [],
  defineConstants: {},
  copy: {
    patterns: [
      {
        from: 'src/images',
        to: 'dist/images'
      },
      {
        from: 'src/components/vant-weapp/dist/wxs',
        to: 'dist/components/vant-weapp/dist/wxs'
      },
      {
        from: 'src/components/vant-weapp/dist/common/style',
        to: 'dist/components/vant-weapp/dist/common/style'
      },
      {
        from: 'src/components/vant-weapp/dist/common/index.wxss',
        to: 'dist/components/vant-weapp/dist/common/index.wxss'
      },
      {
        from: 'src/components/vant-weapp/dist/calendar/index.wxs',
        to: 'dist/components/vant-weapp/dist/calendar/index.wxs'
      },
      {
        from: 'src/components/vant-weapp/dist/calendar/utils.wxs',
        to: 'dist/components/vant-weapp/dist/calendar/utils.wxs'
      },
      {
        from: 'src/components/vant-weapp/dist/calendar/calendar.wxml',
        to: 'dist/components/vant-weapp/dist/calendar/calendar.wxml'
      },
      {
        from:
          'src/components/vant-weapp/dist/calendar/components/month/index.wxs',
        to:
          'dist/components/vant-weapp/dist/calendar/components/month/index.wxs'
      },
      {
        from: 'src/components/vant-weapp/dist/icon/index.wxss',
        to: 'dist/components/vant-weapp/dist/icon/index.wxss'
      },
      {
        from: 'src/components/vant-weapp/dist/icon/index.wxml',
        to: 'dist/components/vant-weapp/dist/icon/index.wxml'
      },
      {
        from: 'src/components/vant-weapp/dist/field/index.wxss',
        to: 'dist/components/vant-weapp/dist/field/index.wxss'
      },
      {
        from: 'src/components/vant-weapp/dist/field/index.wxml',
        to: 'dist/components/vant-weapp/dist/field/index.wxml'
      },
      {
        from: 'src/components/vant-weapp/dist/field/index.wxs',
        to: 'dist/components/vant-weapp/dist/field/index.wxs'
      },
      {
        from: 'src/components/vant-weapp/dist/sticky/index.wxs',
        to: 'dist/components/vant-weapp/dist/sticky/index.wxs'
      },
      {
        from: 'src/components/vant-weapp/dist/tabs/index.wxss',
        to: 'dist/components/vant-weapp/dist/tabs/index.wxss'
      },
      // {
      //   from: "src/components/vant-weapp/dist/tabs/index.wxml",
      //   to: "dist/components/vant-weapp/dist/tabs/index.wxml"
      // },
      {
        from: 'src/components/vant-weapp/dist/tabs/index.wxs',
        to: 'dist/components/vant-weapp/dist/tabs/index.wxs'
      },
      {
        from: 'src/components/vant-weapp/dist/tab/index.wxss',
        to: 'dist/components/vant-weapp/dist/tab/index.wxss'
      },
      {
        from: 'src/components/vant-weapp/dist/tab/index.wxml',
        to: 'dist/components/vant-weapp/dist/tab/index.wxml'
      },
      // { from: 'src/components/vant-weapp/dist/tab/index.wxs', to: 'dist/components/vant-weapp/dist/tab/index.wxs' },
      {
        from: 'src/components/vant-weapp/dist/grid/index.wxss',
        to: 'dist/components/vant-weapp/dist/grid/index.wxss'
      },
      {
        from: 'src/components/vant-weapp/dist/grid/index.wxml',
        to: 'dist/components/vant-weapp/dist/grid/index.wxml'
      },
      {
        from: 'src/components/vant-weapp/dist/grid-item/index.wxss',
        to: 'dist/components/vant-weapp/dist/grid-item/index.wxss'
      },
      {
        from: 'src/components/vant-weapp/dist/grid-item/index.wxml',
        to: 'dist/components/vant-weapp/dist/grid-item/index.wxml'
      },
      {
        from: 'src/components/vant-weapp/dist/grid-item/index.wxss',
        to: 'dist/components/vant-weapp/dist/grid-item/index.wxss'
      },
      {
        from: 'src/components/vant-weapp/dist/grid-item/index.wxml',
        to: 'dist/components/vant-weapp/dist/grid-item/index.wxml'
      },

      {
        from: 'src/components/vant-weapp/dist/area/index.wxml',
        to: 'dist/components/vant-weapp/dist/area/index.wxml'
      },
      {
        from: 'src/components/vant-weapp/dist/area/index.wxss',
        to: 'dist/components/vant-weapp/dist/area/index.wxss'
      },
      {
        from: 'src/components/vant-weapp/dist/popup/index.wxml',
        to: 'dist/components/vant-weapp/dist/popup/index.wxml'
      },
      {
        from: 'src/components/vant-weapp/dist/popup/index.wxss',
        to: 'dist/components/vant-weapp/dist/popup/index.wxss'
      },

      {
        from: 'src/components/vant-weapp/dist/picker-column/index.wxml',
        to: 'dist/components/vant-weapp/dist/picker-column/index.wxml'
      },
      {
        from: 'src/components/vant-weapp/dist/picker-column/index.wxss',
        to: 'dist/components/vant-weapp/dist/picker-column/index.wxss'
      },
      {
        from: 'src/components/vant-weapp/dist/picker-column/index.wxs',
        to: 'dist/components/vant-weapp/dist/picker-column/index.wxs'
      },

      {
        from: 'src/components/vant-weapp/dist/switch/index.wxml',
        to: 'dist/components/vant-weapp/dist/switch/index.wxml'
      },
      {
        from: 'src/components/vant-weapp/dist/switch/index.wxss',
        to: 'dist/components/vant-weapp/dist/switch/index.wxss'
      }
    ],
    options: {}
  },
  alias: {
    '@components': path.resolve(__dirname, '..', 'src/components'),
    '@utils': path.resolve(__dirname, '..', 'src/utils'),
    '@pages': path.resolve(__dirname, '..', 'src/pages'),
    '@requests': path.resolve(__dirname, '..', 'src/requests'),
    '@images': path.resolve(__dirname, '..', 'src/images')
  },
  framework: 'vue',
  mini: {
    postcss: {
      pxtransform: {
        enable: true,
        config: {
          selectorBlackList: [/van-/]
        }
      },
      url: {
        enable: true,
        config: {
          limit: 1024 // 设定转换尺寸上限
        }
      },
      cssModules: {
        enable: false, // 默认为 false，如需使用 css modules 功能，则设为 true
        config: {
          namingPattern: 'module', // 转换模式，取值为 global/module
          generateScopedName: '[name]__[local]___[hash:base64:5]'
        }
      }
    }
  },
  h5: {
    publicPath: '/',
    staticDirectory: 'static',
    postcss: {
      autoprefixer: {
        enable: true,
        config: {}
      },
      cssModules: {
        enable: false, // 默认为 false，如需使用 css modules 功能，则设为 true
        config: {
          namingPattern: 'module', // 转换模式，取值为 global/module
          generateScopedName: '[name]__[local]___[hash:base64:5]'
        }
      }
    }
  }
}

module.exports = function(merge) {
  if (process.env.NODE_ENV === 'development') {
    return merge({}, config, require('./dev'))
  }
  return merge({}, config, require('./prod'))
}
